<?php

if (!defined('UC_FILESYSTEM_ROOT')) 
{
    define('UC_FILESYSTEM_ROOT', dirname(__FILE__) . '/');
}

class UC_PHPFileSystemAutoloader
{
    public static function Register()
    {
        if (function_exists('__autoload')) 
        {
            spl_autoload_register('__autoload');
        }
        
        return spl_autoload_register(array('UC_PHPFileSystemAutoloader', 'Load'));
    }
    
    public static function Load($class_name)
    {
        if ((class_exists($class_name)) || (strpos($class_name, 'UC_PHP') !== 0)) 
        {
            return FALSE;
        }

        $class_file_path = UC_FILESYSTEM_ROOT . 
            DIRECTORY_SEPARATOR . $class_name . '.php';

        if (!file_exists($class_file_path) || !is_readable($class_file_path)) 
        {
            return FALSE;
        }

        require_once $class_file_path;
    }
}

?>
